<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form lay-filter="systemLoginInfoForm" class="layui-form model-form" id="systemLoginInfoForm">
                <input id="id" name="id" type="hidden"/>

                <div class="layui-form-item">
                    <label class="layui-form-label">微信登录</label>
                    <div class="layui-input-block">
                        <input name="wechatLogin" type="checkbox" lay-skin="switch" value="1" lay-text="开启|关闭"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">QQ登录</label>
                    <div class="layui-input-block">
                        <input name="qqLogin" type="checkbox" lay-skin="switch" value="1" lay-text="开启|关闭"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">pc端微信APP_KEY</label>
                    <div class="layui-input-block">
                        <input name="pcWechatAppkey" placeholder="请输入pc端微信appkey" type="text" class="layui-input"
                               lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">pc端微信APP_SECRET</label>
                    <div class="layui-input-block">
                        <input name="pcWechatAppsecret" placeholder="请输入pc端微信appsecret" type="text" class="layui-input"
                               lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">微信公众号APP_KEY</label>
                    <div class="layui-input-block">
                        <input name="emsCnplWechatAppkey" placeholder="请输入微信公众号appkey" type="text" class="layui-input"
                               lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">微信公众号APP_SECRET</label>
                    <div class="layui-input-block">
                        <input name="emsCnplWechatAppsecret" placeholder="请输入微信公众号appsecret" type="text"
                               class="layui-input" lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">QQ APP_KEY</label>
                    <div class="layui-input-block">
                        <input name="qqAppkey" placeholder="请输入QQ appkey" type="text" class="layui-input"
                               lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">QQ APP_SECRET</label>
                    <div class="layui-input-block">
                        <input name="qqAppsecret" placeholder="请输入QQ appsecret" type="text" class="layui-input"
                               lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item text-right">
                    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                    <button class="layui-btn" lay-filter="systemLoginInfoFormSubmit" lay-submit>保存</button>
                </div>
            </form>
        </div>
    </div>
</div>
<style>
    #systemLoginInfoForm .layui-form-label{
        width: 160px;
        padding-left: 0;
    }
    #systemLoginInfoForm .layui-input-block{
        margin-left: 185px;
    }
</style>
<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;
        list();

        //初始化表单
        function list() {
            admin.req('enterprise/system/admin/systemLoginInfo/list', {}, function (res) {
                form.val("systemLoginInfoForm", res.data[0]);
                form.render();
            }, 'GET');
        }

        // 表单提交事件
        form.on('submit(systemLoginInfoFormSubmit)', function (d) {
            if ($("#id").val() != "") {
                admin.req('enterprise/system/admin/systemLoginInfo/update', d.field, function (res) {
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                    list();
                }, 'PUT');
            } else {
                admin.req('enterprise/system/admin/systemLoginInfo/add', d.field, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                    list();
                }, 'POST');
            }
            return false;
        });


    });
</script>